# coding: utf-8
import sys

from qfluentwidgets import (qconfig, QConfig, ConfigItem, OptionsConfigItem, BoolValidator, OptionsValidator, Theme,
                            FolderValidator, ColorConfigItem)
from .settings import CONFIG_FILE, DOWNLOAD_DIR


def isWin11():
    return sys.platform == 'win32' and sys.getwindowsversion().build >= 22000


class Config(QConfig):
    """ 应用程序配置 """
    themeColor = ColorConfigItem("QFluentWidgets", "ThemeColor", '#5f3dc4')
    # folders
    downloadFolder = ConfigItem(
        "Folders", "Download", DOWNLOAD_DIR, FolderValidator())

    # main window
    micaEnabled = ConfigItem("MainWindow", "MicaEnabled", isWin11(), BoolValidator())
    dpiScale = OptionsConfigItem(
        "MainWindow", "DpiScale", "Auto", OptionsValidator([1, 1.25, 1.5, 1.75, 2, "Auto"]), restart=True)
    # lenovo
    lenovoToken = ConfigItem("Lenovo", "Token", "")


cfg = Config()
cfg.themeMode.value = Theme.AUTO
qconfig.load(CONFIG_FILE, cfg)
